home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / pgm_util / sealit / wizard / winexamp / winexamp.c next >
Encoding:
C/C++ Source or Header  |  1996-01-07  |  3.7 KB  |  140 lines

  1. // Kustom Magic Software, Copyright (c) 1995, Ralph Krausse
  2. // File Created on 1/7/96 11:02:00 AM
  3.  
  4. #include <windows.h> 
  5. #include "winexample.h"
  6.  
  7. HINSTANCE hInst;     
  8.  
  9. APPINFO   gAppInfo;  
  10. WINEXAMPLE  WinExample;
  11.  
  12. int PASCAL WinMain(HINSTANCE  hinstCurrent, HINSTANCE hinstPrevious, LPSTR lpszCmdLine, int nCmdShow)
  13. {
  14.     MSG msg;   
  15.     if (!hinstPrevious)  
  16.         if (!InitApplication(hinstCurrent)) 
  17.             return FALSE;      
  18.  
  19.     if (!InitInstance(hinstCurrent, nCmdShow))
  20.         return FALSE;
  21.  
  22.     if (!InitValidation())
  23.         return FALSE;
  24.  
  25.     while (GetMessage(&msg,NULL,NULL,NULL))      
  26.         {
  27.         TranslateMessage(&msg);   
  28.         DispatchMessage(&msg);
  29.         }
  30.     return (msg.wParam);
  31. }
  32.  
  33. BOOL InitValidation(void)
  34. {
  35.   char szPath[_MAX_PATH];
  36.   int wErr = 0,wSealLen = 0;
  37.  
  38.   gAppInfo.bOverWriteSeal = 0;
  39.   strcpy(gAppInfo.szMagicString,"demomagicstring");
  40.  
  41.   getcwd(szPath,100);
  42.   strcat(szPath,"\\winexample.exe");
  43.   strcpy(gAppInfo.szAppName,szPath);
  44.  
  45.   wSealLen = sizeof(WINEXAMPLE);
  46.   if(wErr = ValidateApplication(&gAppInfo, wSealLen, &WinExample))
  47.     {
  48.     if(wErr)
  49.         {
  50.         char szErrorString[250], szDisplayString[350]; 
  51.         GetSealError (wErr, szErrorString);  
  52.         wsprintf(szDisplayString,"Error %d, %s",wErr,szErrorString);
  53.         MessageBox(NULL,szDisplayString,"Validation Error",MB_ICONSTOP);
  54.         return(FALSE);
  55.         }
  56.     }
  57.    return(TRUE);
  58. }
  59.  
  60. BOOL InitApplication(HINSTANCE  hinstCurrent)
  61. {
  62.     WNDCLASS  wc;
  63.     wc.style = NULL;
  64.     wc.lpfnWndProc = MainWndProc;
  65.     wc.cbClsExtra = 0;
  66.     wc.cbWndExtra = 0;
  67.     wc.hInstance = hinstCurrent;   
  68.     wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  69.     wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  70.     wc.hbrBackground = GetStockObject(WHITE_BRUSH);
  71.     wc.lpszMenuName =  "WINEXAMPLEMenu";
  72.     wc.lpszClassName = "WINEXAMPLEClass";
  73.     return (RegisterClass(&wc));
  74. }
  75.  
  76. BOOL InitInstance(HINSTANCE  hinstCurrent, int nCmdShow)
  77. {
  78.  
  79.     HWND hWnd;  
  80.     hInst = hinstCurrent;
  81.     hWnd = CreateWindow("WINEXAMPLEClass","WinExample Sample Application", WS_OVERLAPPEDWINDOW, 
  82.                         CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
  83.                         NULL,NULL,hinstCurrent,NULL );
  84.     if (hWnd == NULL)
  85.       return FALSE;
  86.     ShowWindow(hWnd, nCmdShow);
  87.     UpdateWindow(hWnd);
  88.     return TRUE;
  89. }
  90.  
  91. LRESULT FAR PASCAL MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  92. {
  93.     FARPROC lpProcAbout;
  94.     switch (message)
  95.         {
  96.       case WM_COMMAND:
  97.            if (wParam == IDM_ABOUT)
  98.                 {
  99.           lpProcAbout = MakeProcInstance((FARPROC) About, hInst);
  100.           DialogBox(hInst,"AboutBox",hWnd,(DLGPROC) lpProcAbout);
  101.           FreeProcInstance(lpProcAbout);
  102.           break;
  103.           }
  104.         else if(wParam == IDM_SHOWINFO)
  105.             {
  106.             char szBuffer[100];
  107.             wsprintf(szBuffer,"Magic String: %s",gAppInfo.szMagicString);
  108.             MessageBox(hWnd,szBuffer,"Validation Info",MB_ICONINFORMATION);
  109.             break;
  110.             }
  111.         else
  112.             return (DefWindowProc(hWnd, message, wParam, lParam));
  113.  
  114.         case WM_DESTROY:
  115.                 PostQuitMessage(0);
  116.         break;
  117.  
  118. default:
  119.         return (DefWindowProc(hWnd, message, wParam, lParam));
  120.         }
  121.         return NULL;
  122. }
  123.  
  124. BOOL FAR PASCAL About(HWND hDlg, WORD message, WPARAM wParam, LPARAM lParam)
  125. {
  126.     switch (message)
  127.         {
  128.         case WM_COMMAND:
  129.           if (wParam == IDOK || wParam == IDCANCEL)
  130.             {
  131.           EndDialog(hDlg, TRUE);
  132.           return TRUE;
  133.           }
  134.           break;
  135.         }
  136.         return FALSE;
  137. }
  138.  
  139.  
  140.